<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-form-item class="no-warn-item" label="批次号:" prop="batchNo">
          <el-input v-model="formModel.batchNo" clearable/>
        </el-form-item>
        <el-form-item class="no-warn-item" label="计划年份:" prop="planYear">
          <el-date-picker
            v-model="formModel.planYear"
            :disabled="disabledYear"
            @change="changeYear"
            type="year"
            value-format="yyyy"
            placeholder="选择年">
          </el-date-picker>
        </el-form-item>
        <el-form-item class="no-warn-item" label="计划月份:" prop="month">
          <el-date-picker
            v-model="formModel.month"
            :disabled="disabledMonth"
            @change="changeMonth"
            type="month"
            value-format="yyyy-MM"
            placeholder="选择月">
          </el-date-picker>
        </el-form-item>
        <el-form-item class="no-warn-item" label="计划周:" prop="week">
          <el-date-picker
            v-model="formModel.week"
            :disabled="disabledWeek"
            @change="changeWeek"
            type="week"
            format="yyyy年MM月第WW周"
            placeholder="选择周">
          </el-date-picker>
        </el-form-item>
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button type="primary" plain @click="queryList">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" @row-click="handleRowClick" :columns="columns" :is-radio="true">

    </hey-table>
    <el-row class="submit-area">
      <el-col :span="24">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" @click="handleSubmit()">确定</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  export default {
    name: 'BatchPlanDialog',
    props: {

    },
    data() {
      return {
        chooseData:{},
        disabledYear: false,
        disabledMonth: false,
        disabledWeek: false,
        formModel: {
          batchNo: '',
          planYear: '',
          month: '',
          week: '',
          isDelete: '0'
        },
        columns: [
          { title: '批次号', key: 'batchNo'},
          { title: '销售类型', key: 'saleType',clcd:'Key_Sale_Type'},
          { title: '需求类型', key: 'needType',clcd:'need_type_cd'},
          { title: 'VIN年份', key: 'vinYear',clcd:'Key_Vin_ModeYear'},
          { title: '目标国家', key: 'targetCountry',clcd:'Key_Country_Code'},
          { title: '目的地港口', key: 'destinationPort',clcd:'port_cd'},
          { title: '计划年份', key: 'planYear'},
          { title: '计划月份', key: 'planMonth'},
          { title: '计划周', key: 'planWeek'},
          { title: '创建时间', key: 'createTime' },
          { title: '创建人', key: 'createUsername' },
          { title: '最后修改时间', key: 'lastUpdateTime'},
          { title: '最后修改人', key: 'lastUpdateUsername' },
        ],
        rules: {
        }
      }
    },
    computed: {

    },
    mounted() {

    },
    methods: {
      changeYear(value){
        if(value){
          this.formModel.month = ''
          this.formModel.week = ''
          this.disabledYear = false
          this.disabledMonth = true
          this.disabledWeek = true
        }else{
          this.formModel.month = ''
          this.formModel.week = ''
          this.disabledYear = false
          this.disabledMonth = false
          this.disabledWeek = false
        }
      },
      changeMonth(value){
        if(value){
          this.formModel.year = ''
          this.formModel.week = ''
          this.disabledYear = true
          this.disabledMonth = false
          this.disabledWeek = true
        }else{
          this.formModel.year = ''
          this.formModel.week = ''
          this.disabledYear = false
          this.disabledMonth = false
          this.disabledWeek = false
        }
      },
      changeWeek(value){
        if(value){
          this.formModel.year = ''
          this.formModel.month = ''
          this.disabledYear = true
          this.disabledMonth = true
          this.disabledWeek = false
        }else{
          this.formModel.year = ''
          this.formModel.month = ''
          this.disabledYear = false
          this.disabledMonth = false
          this.disabledWeek = false
        }
      },
      queryList() {
        this.$refs.table.query('/teOfmPlanBatch/queryTeOfmPlanBatch', this.formModel, '', false)
      },
      handleSubmit() {
        if(Object.keys(this.chooseData).length==0){
          this.$warn('请单击选中一条数据!')
          return false
        }
        this.$emit('queryBatchPlanSuc', this.chooseData)
        this.closeDialog()
      },
      handleRowClick(row){
        this.chooseData = row
      },
      closeDialog() {
        this.$parent.$emit('update:visible', false)
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>
